package com.yunshang.ys.ui.tab1.tabview;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/6/27.
 */

public class TabVPAdapter extends FragmentPagerAdapter {

    List<Fragment> fragments;
    List<String> titles;

    public TabVPAdapter(FragmentManager fm, List<Fragment> fragments, List<String> titles) {
        super(fm);
        this.fragments = fragments;
        this.titles = titles;
    }

    @Override
    public int getCount() {
        return isEmpty() ? 0 : fragments.size();
    }

    boolean isEmpty() {
        return fragments == null || fragments.size() == 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @Override
    public Fragment getItem(int position) {
        return this.fragments.get(position);

    }
}
